package service;

import domain.Product;
import persistence.ProductDAO;
import persistence.impl.ProductDAOImpl;

import java.util.List;

public class ProductService {
    private ProductDAO productDAO;

    public ProductService(){
        this.productDAO = new ProductDAOImpl();
    }

    public List<Product> searchProducts(String info){
        List<Product> result = productDAO.getProductBySpeciesOrBreed(info, info);
        Product product = productDAO.getProductById(info);
        if(product == null){
            return result;
        }
        result.add(product);
        return result;
    }

    public Product getProductById(String id){
        return productDAO.getProductById(id);
    }
}
